<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * Description of listing_model
 * 
 * @author Subha Sundar Das (subhasundar.das@gmail.com)
 */
class Listing_model extends CI_Model {

//-- Get Listing (Single Row) --//
    function get_listing($id) {
        if ($id) {
            $sql = "Select * from listing_master where id=$id limit 1";
            $query = $this->db->query($sql);
            if ($query->row())
                return $query->row();
            else
                return 0;
        }
    }


//-- Get listings(Multi Row) --//    
    function get_listings($type = 'CAR', $featured = false, $status = 1, $no = NULL, $offset = NULL) {
        if ($type == 'CAR') {
            if ($featured == false) {
                $sql = "Select * from listing_master where type='$type' and status=$status order by id desc limit $no ";
            } else {
                $sql = "Select * from listing_master where type='$type' and featured =1 and status=$status order by id desc limit $no ";
            }
            $query = $this->db->query($sql);
            return $query->result();
        }
    }

    function add($post) {
        if ($post) {
            $this->db->insert('listing_master', $post);
            return "<strong>Thank you!</strong> &nbsp; 
                You have successfully entered your car Information. Please goto  
                <strong>Member Area</strong> for PHOTOS AND OTHER DETAIL.";
        } else {
            return "<strong>Sorry !</strong> &nbsp; Invalid Operation.";
        }
    }

}

?>